﻿/* ----------------------------------------------------------------------------
 * Copyright (c) Philip Stears 
 *
 * This source code is subject to terms and conditions of the Microsoft Public 
 * License (Ms-PL).
 * 
 * By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 * 
 * To request a copy of the Microsoft Public License, send a request by email
 * to license@connectbasic.net.
 *
 * This notice must not be removed from this software.
 * ---------------------------------------------------------------------------- */

namespace ConnectBasic.Shell.Implementation
{
    using System;
    using System.Collections.Generic;
    using ConnectBasic.Shell.Extensibility;
    using ConnectBasic.Shell.Hosting;

    /// <summary>
    /// Provides an <see cref="IProjectCollection" /> wrapper
    /// around an <see cref="IShellHostProjectCollection" />.
    /// </summary>
    internal class DefaultShellProjectCollection : IProjectCollection
    {
        private IShellHostProjectCollection mProjects;

        internal DefaultShellProjectCollection(IShellHostProjectCollection projects)
        {
            if (projects == null) throw new ArgumentNullException("projects");
            mProjects = projects;
        }

        #region IProjectCollection Members

        private EventHandler<ProjectEventArgs> mProjectLoadedEvent;

        event EventHandler<ProjectEventArgs> IProjectCollection.ProjectLoaded
        {
            add { mProjectLoadedEvent += value; }
            remove { mProjectLoadedEvent -= value; }
        }

        int IProjectCollection.Count
        {
            get { return mProjects.Count; }
        }

        IProject IProjectCollection.this[int index]
        {
            get { return mProjects[index]; }
        }

        #endregion

        #region IEnumerable<IProject> Members

        IEnumerator<IProject> IEnumerable<IProject>.GetEnumerator()
        {
            return mProjects.GetEnumerator();
        }

        #endregion

        #region IEnumerable Members

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return mProjects.GetEnumerator();
        }

        #endregion
    }
}
